package com.myzk.example.controller;

import com.myzk.example.core.Result;
import com.myzk.example.core.ResultUtil;
import com.myzk.example.error.BizException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.context.support.WebApplicationObjectSupport;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;

/**
 * @author mayong
 * @date 2020年11月10日16:19:24
 */
public class BaseController extends WebApplicationObjectSupport {

    @Autowired
    protected HttpServletRequest request;

    @ExceptionHandler(BizException.class)
    public Result<Map> bizRuntimeExceptionHandler(BizException ex) {
        //ex.printStackTrace();
        Result errorResult = ResultUtil.error("-1", ex.toString());
        return errorResult;
    }
}
